<table border="0" cellpadding="0" cellspacing="0" width="90%" >
<tr>
<td width="10%"><img border="0" src="images/king_logo.gif" width="150" height="150"></td>
<td >
<p align="center"><font face="Arial" size="6">King of Enterprises</font></p>
<p align="center"><font face="Lucida Handwriting" size="3"><A HREF="reseller_rep_xls.php"><img src="images/xls.jpg" width="25" height="25" />Registered Resellers Report(xls)</A></font></p>
<p align="center"><font face="Lucida Handwriting" size="3"><A HREF="reseller_rep.csv"><img src="images/csv.jpg" width="25" height="25" longdesc="images/csv.jpg" />Registered Resellers Report(csv)</A></font></p></td>
<!--<td width="201" height="150"></td>-->
</tr>
</table>
<?php
	//include_once("king_head.php");
	include_once("config.php");
?>
<CENTER>
<font face="verdana">
<table border="2" cellpadding="0" cellspacing="0"  width="100%">
  <tr>
    <th width="17%">Site Id</th>
    <th width="17%">Name</th>
    <th width="17%">e-mail</th>
    <th width="17%">Contact No.</th>
    <th width="17%">Mobile No.</th>
    <th width="15%">Address</th>
  </tr> 
<?php
$sql="Select * from reseller order by site_id";
$res=mysql_query($sql);
while($row=mysql_fetch_array($res))
{
	$siteid=$row["site_id"];
	$name=$row["title"]." ".$row["fname"];
	$eml=$row["email"];
	$contact=$row["contact_no"];
	$mobile=$row["mobile_no"];	$Address="&nbsp;".$row["adress"]."&nbsp;<BR>".$row["city"]."&nbsp;<BR>".$row["province"]."&nbsp;<BR>".$row["country"]."&nbsp;<BR>Zip:".$row["zip"];
	echo"<tr>";
	echo"<td width=\"17%\">&nbsp;".$siteid."</td>";
    echo"<td width=\"17%\">&nbsp;".$name."</td>";
    echo"<td width=\"17%\">&nbsp;".$eml."</td>";
    echo"<td width=\"17%\">&nbsp;".$contact."</td>";
    echo"<td width=\"17%\">&nbsp;".$mobile."</td>";
    echo"<td width=\"15%\">&nbsp;".$Address."</td>";    
	echo"</tr>";
}   
?> 
</TABLE></font>
</CENTER>
</strong>
<?php
	include_once("king_foot.php");	
//Creating CSV File.
$cqry="Select * from reseller order by site_id";
$cres=mysql_query($cqry);
if(file_exists("reseller_rep.csv"))
{
unlink("reseller_rep.csv");
}
//Create New file.
$fp=fopen("reseller_rep.csv","a+");
$record='"Site Id","Name","Email","Phone","Mobile","Address","State\Province","Country","Zip"'."\n";
fwrite($fp,$record);

while($rec=mysql_fetch_array($cres))
{
$_SESSION['SITE_ID']=$rec["site_id"];
$name=$rec["title"]." ".$rec["fname"];
$eml=$rec["email"];
$contact=$rec["phone_no"];
$mobile=$rec["mobile_no"];
$Address=" ".$rec["adress1"]." ".$rec["adress2"]." ".$rec["city"];
$prov=$rec["province"];
$country=$rec["country"];
$Zip=$rec["zip"];
$record='"'.$_SESSION['SITE_ID'].'","'.$name.'","'.$eml.'","'.$contact.'","'.$mobile.'","'.$Address.'","'.$prov.'","'.$country.'","'.$Zip.'"'."\n";
//echo $record.'<BR>';
fwrite($fp, $record);
}
fclose($fp);
?>